{% extends "metadata_base.html" %}
{% load i18n %}
{% load bootstrap_tags %}
{% load base_tags %}
{% load guardian_tags %}
{% load floppyforms %}
{% load client_lib_tags %}

{% block title %}{{ dataset.alternate }} — {{ block.super }}{% endblock title %}

{% block head %}
    {% include "ol/datasets/dataset_ol2_map.html" %}
{{ block.super }}
{% endblock head %}

{% block body_class %}data{% endblock body_class %}

{% block body_outer %}
<div class="container-fluid page-header" style="position: relative;">
  <h2 class="page-title">{% trans "Metadata" %}&nbsp;{% blocktrans with dataset.title as dataset_title %}for {{ dataset_title }}{% endblocktrans %}</h2>
      <div id="profileCompleteness" class="alert alert-info" style="position: absolute; right: 0; top: 0; padding: 4px;">
        <strong>{% trans "Completeness" %}</strong>
        <div style="padding: 2px;">
          <small class="completed text-success" style="display: none; "><i class="fa fa-check"></i>{% trans "Metadata Schema mandatory fields completed" %}</small>
          <small class="not-completed text-danger" style="display: none; "><i class="fa fa-remove"></i>{% trans "Check Schema mandatory fields" %}</small>
        </div>
        <div class="progress" style="margin-bottom:2px;">
        <div class="progress-bar progress-bar-striped" role="progress-bar" >
          70%
        </div>
        </div>
      </div>
  </h2>
</div>

    <form id="metadata_update" class="form-horizontal" action="{% url "dataset_metadata" dataset.service_typename %}" method="POST">
      {% if dataset.metadata_uploaded_preserve %}
        <p class="bg-warning">{% blocktrans %}Note: this layer's orginal metadata was populated and preserved by importing a metadata XML file.
          This metadata cannot be edited.{% endblocktrans %}</p>
      {% elif dataset.metadata_uploaded %}
        <p class="bg-warning">{% blocktrans %}Note: this layer's orginal metadata was populated by importing a metadata XML file.
          GeoNode's metadata import supports a subset of ISO, FGDC, and Dublin Core metadata elements.
          Some of your original metadata may have been lost.{% endblocktrans %}</p>
      {% endif %}

      {% if dataset_form.errors or attribute_form.errors or category_form.errors or metadata_author_form.errors or poc.errors or tkeywords_form.errors %}
    	  <p class="bg-danger">{% blocktrans %}Error updating metadata.  Please check the following fields: {% endblocktrans %}</p>
          <ul class="bg-danger">
          {% if metadata_author_form.errors %}
            <li>{% trans "Metadata Author" %}</li>
            {{ metadata_author_form.errors }}
          {% endif %}
          {% if poc_form.errors %}
            <li>{% trans "Point of Contact" %}</li>
            {{ poc_form.errors }}
          {% endif %}
          {% for field in dataset_form %}
            {% if field.errors %}
            <li>{{ field.label }}</li>
            {% endif %}
          {% endfor %}
          {% if not attribute_form.is_valid %}
            <li>{% trans "Attributes" %}</li>
            {% for field in attribute_form %}
            {% if field.errors %}
            <li>{{ field.errors }}</li>
            {% endif %}
            {% endfor %}
          {% endif %}
          {% if category_form.errors %}
            <li>{{ category_form.errors.as_ul }}</li>
          {% endif %}
          {% if tkeywords_form.errors %}
            <li>{{ tkeywords_form.errors.as_ul }}</li>
          {% endif %}
          </ul>
        {% endif %}

        {% csrf_token %}
        <div id="mdeditor_form" class="col-md-12 form-controls">
          {% form dataset_form using panel_template %}
          {# dataset_form|as_bootstrap #}
        </div>

        <div class="row">
          <div class="col-md-12 grid-spacer">
            <fieldset class="form-controls modal-forms modal hide fade" id="poc_form" >
              <h2>{% trans "Point of Contact" %}</h2>
              {{ poc_form|as_bootstrap }}
              <button type='button' class="modal-cloose-btn btn btn-primary">{% trans "Done" %}</button>
            </fieldset>
            <fieldset class="form-controls modal-forms modal hide fade" id="metadata_form">
              <h2>{% trans "Metadata Provider" %}</h2>
                {{ metadata_author_form|as_bootstrap }}
              <button type='button' class="modal-cloose-btn btn btn-primary">{% trans "Done" %}</button>
            </fieldset>

            {% if not dataset.metadata_uploaded_preserve %}
            <div class="form-actions">
              <a href="{{ resource.get_absolute_url }}" class="btn btn-primary">{% trans "Return to Dataset" %}</a>
              <input type="button" id="btn_back_dwn" class="btn btn-primary" style="display: none" value="{% trans "<< Back" %}"/>
              <input type="submit" id="btn_upd_md_dwn" class="btn btn-primary" value="{% trans "Update" %}"/>
              <input type="button" id="btn_next_dwn" class="btn btn-primary" value="{% trans "Next >>" %}"/>
            </div>
            {% endif %}
          </div>
        </div>
      </form>

{{ block.super }}
{% endblock body_outer %}
